<template>
  <div>
    <el-dialog title="入库单" :visible.sync="centerDialogVisible" width="80%">
      <el-table
        :data="subWaybills"
        height="600"
        style="width:100%; "
        :row-class-name="tableRowClassName"
      >
        <el-table-column prop="subWaybillNo" label="序号" width="40">
        </el-table-column>
        <el-table-column prop="boxNo" label="外箱号" width="180">
        </el-table-column>
        <el-table-column prop="trackNumber" label="追踪号" width="180">
        </el-table-column>
        <el-table-column prop="trackType" label="类型">
          <template slot-scope="scope">
            {{ scope.row.trackType }}
          </template>
        </el-table-column>

        <el-table-column prop="weight" label="重量"> </el-table-column>
        <el-table-column prop="length" label="长"> </el-table-column>
        <el-table-column prop="width" label="宽"> </el-table-column>
        <el-table-column prop="height" label="高"> </el-table-column>
        <el-table-column prop="totalVolum" label="体积"> </el-table-column>
        <el-table-column prop="volumeWeight" label="体积重"> </el-table-column>
        <el-table-column prop="chargedWeight" label="计费重"> </el-table-column>
        <el-table-column prop="labelUrl" label="标签">
          <template slot-scope="scope">
            <div
              v-if="scope.row.labelUrl && scope.row.labelUrl.endsWith('pdf')"
            >
              <span @click="previewFile(scope.row.labelUrl)">pdf</span>
            </div>
            <div v-else @click="previewFile(scope.row.labelUrl)">
              <el-image
                v-if="!scope.row.labelUrl.endsWith('null')"
                :src="scope.row.labelUrl"
              ></el-image>
              <span v-else>无面单</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-row>
        <el-col :span="2">总计：</el-col>
        <el-col :span="4"
          >入库实重:{{ Constatvariable.inStockActualWeight }}</el-col
        >
        <el-col :span="4">入库体积:{{ Constatvariable.inStockVolume }}</el-col>
        <el-col :span="4"
          >入库计费重:{{ Constatvariable.inStockChargedWeight }}</el-col
        >
        <el-col :span="4"
          >入库体积重:{{ Constatvariable.inStockVolumeWeight }}</el-col
        >
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

import { m } from "@/store/yg/common/local";

export default {
  props: {
    subWaybills: {
      type: Array,
      default: []
    },
    Constatvariable: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  methods: {
    previewFile(labelUrl) {
      window.open(labelUrl, "_blank");
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return "warning-row";
      } else if (rowIndex === 3) {
        return "success-row";
      }
      return "";
    }
  },
  data() {
    return {
      centerDialogVisible: false
    };
  }
};
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>
